package com.appsys.uitl;
import java.util.HashMap;
import java.util.List;
	/**
	 * 分页工具类，封装每页需要显示的数据
	 * 
	 * 参数--页面参数：分页，业务
	 * 
	 * 数据--数据库中的数据：总行数，数据集
	 * @param <T>
	 */
	public class pageUtil<T>{
		
	//当前页码(1,2,3.......)
	private Integer pageNo=1;
	public Integer getPageNo() {
		return pageNo;
	}

	public void setPageNo(Integer pageNo) {
		this.pageNo = pageNo;
		this.params.put("pageNo", pageNo);
	}

	public Integer getPageSize() {
		return pageSize;
	}

	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
		this.params.put("pageSize", pageSize);
	}

	public Integer getTotalCount() {
		return totalCount;
	}

	public void setTotalCount(Integer totalCount) {
		this.totalCount = totalCount;
	}

	public HashMap<String, Object> getParams() {
		this.params.put("stratRow", (pageNo-1)*pageSize);
		return params;
	}

	public void setParams(HashMap<String, Object> params) {
		this.params = params;
	}

	public Integer getTotalSize() {
		return totalSize;
	}

	public void setTotalSize(Integer totalSize) {
		this.totalSize = totalSize;
	}

	public List<T> getResults() {
		return results;
	}

	public void setResults(List<T> results) {
		this.results = results;
	}

	//每页显示条数
	private Integer pageSize=10;
	
	//总记录(条数)
	private Integer totalCount;
	
	//当前数据集合
	private HashMap<String, Object> params = new HashMap<String, Object>();
	
	//总行数
	private Integer totalSize = 0;
	
	//当前查询条件下的记录
	private List<T> results;
	public pageUtil(){
		this.params.put("pageNo", pageNo);
		this.params.put("pageSize", pageSize);
	}
	//分页计算
	public Integer getTotalPage(){
		int totalPage = this.totalSize/this.pageSize;
		if (this.totalSize%this.pageSize!=0) {
			totalPage++;
		}
		return totalPage;
	}
}
